package com.this1;

/**
 * Time    : 2023/3/18 15:35
 * Author  : 王摇摆
 * FileName: Test1.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

public class Test {
    public static void main(String[] args) {
//        People p1; //创建指向people类对象的引用
//        People p2 = new People(); //new的作用是为对象开辟内存并初始化，将对象复制给引用
//        p2.setName("wgw");
//        p2.setId("07034");

        People p1 = new People("David","0002");
        People p2 = new People("David","0002");
        System.out.println(p1 == p2);

    }
}

class People {
    String name;
    String id;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public People(String name, String id) {
        this.name = name;
        this.id = id;
        System.out.println("people类的有参构造器已执行");
    }

    public People() {
        System.out.println("people类的无参构造器已执行");
    }
}
